package com.interview.ujiuye7;

import java.io.*;
import java.net.ServerSocket;
import java.net.Socket;

public class MyServer {
    public static void main(String[] args) throws Exception{
        System.out.println("服务器启动成功.......");
        ServerSocket serverSocket = new ServerSocket(8080);//银行的大堂经理
        Socket socket = serverSocket.accept();//办事的柜员: 银行招聘柜员，

        InputStream inputStream = socket.getInputStream();
        InputStreamReader reader = new InputStreamReader(inputStream);
        BufferedReader br = new BufferedReader(reader);
        String line = br.readLine();
        System.out.println("服务器接到数据:"+line);
        //返回数据
        OutputStream os = socket.getOutputStream();
        OutputStreamWriter osw =new OutputStreamWriter(os);
        osw.write(line);
        osw.close();
        serverSocket.close();
    }
}
